import createRouter from '@/uni_modules/zzh-simple-router/js_sdk/router/router.js'
const router = createRouter()
router.encode = 0

const whiteList = ['pages/index/index'] // 除了这些路径，其他都必须登录

// 全局路由拦截器
router.before = function(from, next) {
	const hasPermission = whiteList.find(rule => (from.url).includes(rule))
	// if (!hasPermission) {
	// 	uni.showModal({
	// 		title: '温馨提示',
	// 		content: '是否前往登录',
	// 		success: (res) => {
	// 			console.log(res);
	// 			if (res.confirm) {
	// 				next('pages/login/index')
	// 			}
	// 		}
	// 	})
	// 	return
	// }
	// console.log(from);
	next()
}

router.after = to => {
	// console.log(to);
	return to
}

router.onError = err => {
	console.log(err)
}

export default router